const {
	apiDetailModifyHistory,
} = require('./api-utils-history-2x')

module.exports = {
	/**
	 * contet-type变更方法
	 * @return {[type]} [description]
	 */
	contentTypeChange(newValue, oldValue) {
		if (!this.store.isLock)
			return false
		if (!this.store.record)
			return false
		let _currentEditApiDetail = this.store._currentEditApiDetail
		if (_currentEditApiDetail) {
			_currentEditApiDetail.contentType = newValue
			apiDetailModifyHistory.call(this, 'contentType', newValue, oldValue)
		}
	},

	/**
	 * [urlChange description]
	 * @param  {[type]} newValue [description]
	 * @param  {[type]} oldValue [description]
	 * @return {[type]}          [description]
	 */
	pathChange(newValue, oldValue) {
		if (!this.store.isLock)
			return false
		if (!this.store.record)
			return false
		let _currentEditApiDetail = this.store._currentEditApiDetail
		let moduleId = this.store._currentCheckApiDetail && this.store._currentCheckApiDetail.id;
		if (_currentEditApiDetail) {
			_currentEditApiDetail.path = newValue
			apiDetailModifyHistory.call(this, 'path', newValue, oldValue, moduleId)
		}
	},

	/**
	 * [methodChange description]
	 * @return {[type]} [description]
	 */
	methodChange(newValue, oldValue) {
		if (!this.store.isLock)
			return false
		if (!this.store.record)
			return false
		let _currentEditApiDetail = this.store._currentEditApiDetail
		let moduleId = this.store._currentCheckApiDetail && this.store._currentCheckApiDetail.id;
		if (_currentEditApiDetail) {
			_currentEditApiDetail.method = newValue
			apiDetailModifyHistory.call(this, 'method', newValue, oldValue, moduleId)
		}
	},

	/**
	 * [introChange description]
	 * @return {[type]} [description]
	 */
	introChange(newValue, oldValue) {
		if (!this.store.isLock)
			return false
		if (!this.store.record)
			return false
		let _currentEditApiDetail = this.store._currentEditApiDetail
		let moduleId = this.store._currentCheckApiDetail && this.store._currentCheckApiDetail.id;
		if (_currentEditApiDetail) {
			_currentEditApiDetail.intro = newValue
			apiDetailModifyHistory.call(this, 'intro', newValue, oldValue, moduleId)
		}
	},

	onLoadSuccess(data) {
		if (!this.store.isLock)
			return false
		this.store.record = true
	},
}